#!/usr/bin/env python3
# --*--  coding: utf8 --*--

# python 100天从新手到大师
# https://github.com/jackfrued/Python-100-Days

# Day4 execise
# for i  in range(1, 6):
#     print(i * "*")
#
# for i  in range(1, 6):
#     print(' ' * (6-i) +  '*' * i)
#
# for i  in range(1, 11, 2):
#     blank = int(( 11 - i ) / 2)
#     # print(blank)
#     print(' ' * blank +  '*' * i + ' ' * blank )

# Day 5 百钱百鸡
# 说明：百钱百鸡是我国古代数学家张丘建在《算经》一书中提出的数学问题：
# 鸡翁一值钱五，鸡母一值钱三，鸡雏三值钱一。百钱买百鸡，问鸡翁、鸡母、鸡雏各几何？
# 翻译成现代文是：公鸡5元一只，母鸡3元一只，小鸡1元三只，用100块钱买一百只鸡，问公鸡、母鸡、小鸡各有多少只？

# for gongji in range(0, 21):
#     for muji in range(0, 34):
#         xiaoji = 100 - gongji - muji
#         if gongji * 5 + muji * 3 +  xiaoji / 3 == 100:
#             print('gongji:' + str(gongji), 'muji:' + str(muji), 'xiaoji:' + str(xiaoji))

# day 6

# def add(a=1, b=2, c=3):
#     """三个数相加"""
#     return a + b + c
# print(add())
# print(add(2, b=1))

def foo():
    b = 'hello'
    # Python中可以在函数内部再定义函数
    def bar():
        c = True
        print(a)
        print(b)
        print(c)
    bar()
    # print(c)  # NameError: name 'c' is not defined
if __name__ == '__main__':
    a = 100
    # print(b)  # NameError: name 'b' is not defined
    foo()